package com.taptech.doufu.ui.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.CenterCrop;
import com.taptech.doufu.R;
import com.taptech.doufu.app.WeMediaApplication;
import com.taptech.doufu.manager.UserLogManager;
import com.taptech.doufu.bean.DFHomeNovelBeans;
import com.taptech.doufu.bean.DFHomeNovelContentBeans;
import com.taptech.doufu.bean.EventBean;
import com.taptech.doufu.bean.cp.ResponseCpIndexDataBean;
import com.taptech.doufu.constant.Constant;
import com.taptech.doufu.ui.activity.NovelDetailsActivity;
import com.taptech.doufu.ui.view.topicview.ContentType;
import com.taptech.doufu.ui.view.topicview.NovelTopicComicGridView;
import com.taptech.doufu.ui.view.topicview.NovelTopicRankView;
import com.taptech.doufu.util.GlideRoundTransform;
import com.taptech.doufu.util.GlideUtil;
import com.taptech.doufu.util.StartActivityUtils;
import com.taptech.doufu.util.StringUtil;
import com.taptech.doufu.util.TMAnalysis;
import com.taptech.doufu.util.TagsUtil;
import com.taptech.doufu.ui.view.topicview.AuthorFiveItemView;
import com.taptech.doufu.ui.view.topicview.AuthorHorizontalView;
import com.taptech.doufu.ui.view.topicview.NovelTopicBannerView;
import com.taptech.doufu.ui.view.topicview.NovelTopicBookListView;
import com.taptech.doufu.ui.view.topicview.NovelTopicCategoryPlusView;
import com.taptech.doufu.ui.view.topicview.NovelTopicCategorytView;
import com.taptech.doufu.ui.view.topicview.NovelTopicHorizontalView;
import com.taptech.doufu.ui.view.topicview.NovelTopicImageView;
import com.taptech.doufu.ui.view.topicview.NovelTopicLimitTimeView;
import com.taptech.doufu.ui.view.topicview.NovelTopicNomalView;
import com.taptech.doufu.ui.view.topicview.NovelTopicSimpleView;
import com.taptech.doufu.ui.view.topicview.NovelTopicTagView;
import com.taptech.doufu.ui.view.topicview.NovelTopicGridView;
import com.taptech.doufu.ui.view.topicview.NovelTopicType;
import com.taptech.doufu.ui.view.topicview.UmengEventUtil;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 小说列表适配器
 */
public class DfhomeNovelAdapter3 extends BaseAdapter {
    private Context context;
    private List<Object> contentList = new ArrayList<>();
    private String sexType;
    private String pageType;
    private String cardTitle;
    private static final int NovelSingle = 0;
    private static final int NovelRank = 1;
    private static final int NovelSimple = 2;
    private static final int NovelNomal = 3;
    private static final int NovelLike = 4;
    private static final int NovelTag = 5;
    private static final int NovelSale = 6;
    private static final int NovelBanner = 7;
    private static final int BookList = 8;
    private static final int Image = 9;
    private static final int LimitTime = 10;
    private static final int Categorty  = 11;
    private static final int Grid = 12;
    private static final int CategortyPlus  = 13;
    private static final int DSRecommend  = 14; //大神
    private static final int HSRecommend  = 15;  //化神
    private static final int TopRank  = 16;  //前十排行
    private static final int Comic  = 17;  //漫画


    public DfhomeNovelAdapter3(Context context, List<Object> contentList, String sexType) {
        this.context = context;
        if (contentList != null) {
            this.contentList = contentList;
        }
        this.sexType = sexType;
    }

    public void setPageType(String pageType) {
        this.pageType = pageType;
    }

    public void refrushList(List<Object> contentList) {
        if (contentList != null) {
            this.contentList = contentList;
            notifyDataSetChanged();
        }
    }

    @Override
    public int getCount() {
        if (contentList != null) {
            return contentList.size();
        }else{
            return 0;
        }
    }

    @Override
    public int getViewTypeCount() {
        return 18;
    }

    @Override
    public int getItemViewType(int position) {
        Object object = getItem(position);
        if( object instanceof ResponseCpIndexDataBean.DataBean.ListBean){
            ResponseCpIndexDataBean.DataBean.ListBean data = (ResponseCpIndexDataBean.DataBean.ListBean) object;
            if(data.getModel() == NovelTopicType.TFHomeNovelModelTypeTag){  //标签
                return NovelTag;
            }else{  //轮播图
                return NovelBanner;
            }
        }else if (object instanceof DFHomeNovelContentBeans){
            DFHomeNovelContentBeans data = (DFHomeNovelContentBeans) object;
            if (data.getModel() == NovelTopicType.TFHomeNovelModelTypeNovelSingle){//等分
                return NovelSingle;
            }else if(data.getModel() == NovelTopicType.TFHomeNovelModelTypeNovelRank){//可左右滑动
                return NovelRank;
            }else if (data.getModel() == NovelTopicType.TFHomeNovelModelTypeNovelLastest ){//最近更新
                return NovelSimple;
            }else if(data.getModel() == NovelTopicType.TFHomeNovelModelTypeSale){  //打折
                return NovelSale;
            }else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeBookList){
                return BookList;
            }else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeImage){
                return Image;
            } else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeLimitTime){
                return LimitTime;
            } else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeCategorty){
                return Categorty;
            } else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeTwoLine){
                return Grid;
            }  else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeCategortyPlus){
                return CategortyPlus;
            }  else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeDSRecommend){
                return DSRecommend;
            }  else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeHSRecommend){
                return HSRecommend;
            } else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeTopRank){
                return TopRank;
            } else if(data.getModel() == NovelTopicType.TFHomeNovelModeTypeComic){
                return Comic;
            } else {  //普通
                return NovelNomal;
            }
        } else{
            return NovelLike;
        }
    }

    @Override
    public Object getItem(int position) {
        if (contentList != null && contentList.size() > position) {
            return contentList.get(position);
        }else{
            return null;
        }
    }

    @Override
    public long getItemId(int position) {
        return position;
    }


    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {
        int itemViewType = getItemViewType(position);
        Object data = getItem(position);
        switch (itemViewType){
            case NovelNomal:
                DFHomeNovelContentBeans model1 = (DFHomeNovelContentBeans)data;
                model1.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicNomalView(context,model1, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model1.getTitle())){
                    }else{
                        convertView = new NovelTopicNomalView(context,model1, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case NovelSimple:
                DFHomeNovelContentBeans model2 = (DFHomeNovelContentBeans)data;
                model2.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicSimpleView(context,model2, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model2.getTitle())){
                    }else{
                        convertView = new NovelTopicSimpleView(context,model2, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case NovelRank:
                DFHomeNovelContentBeans model3 = (DFHomeNovelContentBeans)data;
                model3.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicHorizontalView(context,model3, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model3.getTitle())){
                    }else{
                        convertView = new NovelTopicHorizontalView(context,model3, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case NovelBanner:
                ResponseCpIndexDataBean.DataBean.ListBean model4 = (ResponseCpIndexDataBean.DataBean.ListBean)data;
                if (convertView == null){
                    convertView = new NovelTopicBannerView(context,model4, sexType,position,pageType);
                    convertView.setTag(((ResponseCpIndexDataBean.DataBean.ListBean) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model4.getTitle())){
                    }else{
                        convertView = new NovelTopicBannerView(context,model4, sexType,position,pageType);
                        convertView.setTag(((ResponseCpIndexDataBean.DataBean.ListBean) data).getTitle());
                    }
                }
                break;
            case NovelTag:
                ResponseCpIndexDataBean.DataBean.ListBean model5 = (ResponseCpIndexDataBean.DataBean.ListBean)data;
                if (convertView == null){
                    convertView = new NovelTopicTagView(context,model5, sexType,position,pageType);
                    convertView.setTag(((ResponseCpIndexDataBean.DataBean.ListBean) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model5.getTitle())){
                    }else{
                        convertView = new NovelTopicTagView(context,model5, sexType,position,pageType);
                        convertView.setTag(((ResponseCpIndexDataBean.DataBean.ListBean) data).getTitle());
                    }
                }

                break;
            case NovelSale:
                DFHomeNovelContentBeans model6 = (DFHomeNovelContentBeans)data;
                model6.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicGridView(context,model6, sexType, ContentType.PRICE,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model6.getTitle())){
                    }else{
                        convertView = new NovelTopicGridView(context,model6, sexType,ContentType.PRICE,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case BookList:
                DFHomeNovelContentBeans model7 = (DFHomeNovelContentBeans)data;
                model7.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicBookListView(context,model7, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model7.getTitle())){
                    }else{
                        convertView = new NovelTopicBookListView(context,model7, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case Image:
                DFHomeNovelContentBeans model8= (DFHomeNovelContentBeans)data;
                model8.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicImageView(context,model8,sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model8.getTitle())){
                    }else{
                        convertView = new NovelTopicImageView(context,model8,sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case LimitTime:
                DFHomeNovelContentBeans model9= (DFHomeNovelContentBeans)data;
                model9.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicLimitTimeView(context,model9,sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model9.getTitle())){
                    }else{
                        convertView = new NovelTopicLimitTimeView(context,model9,sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case Categorty:
                DFHomeNovelContentBeans model10= (DFHomeNovelContentBeans)data;
                model10.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicCategorytView(context,model10,sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model10.getTitle())){
                    }else{
                        convertView = new NovelTopicCategorytView(context,model10,sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case CategortyPlus:
                DFHomeNovelContentBeans model11= (DFHomeNovelContentBeans)data;
                model11.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicCategoryPlusView(context,model11,sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model11.getTitle())){
                    }else{
                        convertView = new NovelTopicCategoryPlusView(context,model11,sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case NovelSingle:
            case Grid:
                DFHomeNovelContentBeans model12 = (DFHomeNovelContentBeans)data;
                model12.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicGridView(context,model12, sexType, ContentType.TAG,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model12.getTitle())){
                    }else{
                        convertView = new NovelTopicGridView(context,model12, sexType,ContentType.TAG,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case DSRecommend:
                DFHomeNovelContentBeans model13 = (DFHomeNovelContentBeans)data;
                model13.setListPos(position);
                if (convertView == null){
                    convertView = new AuthorFiveItemView(context,model13, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model13.getTitle())){
                    }else{
                        convertView = new AuthorFiveItemView(context,model13, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case HSRecommend:
                DFHomeNovelContentBeans model14 = (DFHomeNovelContentBeans)data;
                model14.setListPos(position);
                if (convertView == null){
                    convertView = new AuthorHorizontalView(context,model14, sexType,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model14.getTitle())){
                    }else{
                        convertView = new AuthorHorizontalView(context,model14, sexType,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;


            case Comic:
                DFHomeNovelContentBeans model15 = (DFHomeNovelContentBeans)data;
                model15.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicComicGridView(context,model15, sexType, ContentType.TAG,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model15.getTitle())){
                    }else{
                        convertView = new NovelTopicComicGridView(context,model15, sexType,ContentType.TAG,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case TopRank:
                DFHomeNovelContentBeans model16 = (DFHomeNovelContentBeans)data;
                model16.setListPos(position);
                if (convertView == null){
                    convertView = new NovelTopicRankView(context,model16, sexType, ContentType.TAG,pageType);
                    convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                }else{
                    if (convertView.getTag().toString().equals(model16.getTitle())){
                    }else{
                        convertView = new NovelTopicRankView(context,model16, sexType,ContentType.TAG,pageType);
                        convertView.setTag(((DFHomeNovelContentBeans) data).getTitle());
                    }
                }
                break;
            case NovelLike:
                ViewHolder viewHolder ;
                if (convertView == null||convertView.getTag() == null) {
                    viewHolder = new ViewHolder();
                    convertView = View.inflate(context, R.layout.dfnovel_item2, null);
                    viewHolder.tv_bigtitle = (TextView) convertView.findViewById(R.id.dfnovel_type_title);
                    viewHolder.tv_more = (TextView) convertView.findViewById(R.id.dfnovel_icon_moretext);
                    viewHolder.novelIcon1 = (ImageView) convertView.findViewById(R.id.draweeview1_dfnovel);
                    viewHolder.tv_title1 = (TextView) convertView.findViewById(R.id.tv_dfnovel_title1);
                    viewHolder.tv_des1 = (TextView) convertView.findViewById(R.id.tv_dfnovel_des1);
                    viewHolder.tv_author1 = (TextView) convertView.findViewById(R.id.tv_dfnovel_author_info1);
                    viewHolder.tv_tag11 = (TextView) convertView.findViewById(R.id.tv_dfnovel_tag11);
                    viewHolder.tv_tag12 = (TextView) convertView.findViewById(R.id.tv_dfnovel_tag12);
                    viewHolder.linearLayout0 = (LinearLayout) convertView.findViewById(R.id.home_dfnovel_layout0);
                    viewHolder.rela1 = (RelativeLayout) convertView.findViewById(R.id.rl_dfnovel_layout1);
                    viewHolder.imgVip = (ImageView) convertView.findViewById(R.id.img_dfnovel_item2_vip);
                    viewHolder.rootLayout =  (LinearLayout)convertView.findViewById(R.id.img_dfnovel_item2_layout);
                    convertView.setTag(viewHolder);
                } else {
                    viewHolder = (ViewHolder) convertView.getTag();
                }
                changeDayModelBg(viewHolder);
                setData(viewHolder, (DFHomeNovelBeans)data,position);
                setListener(viewHolder, (DFHomeNovelBeans)data,position);
                break;
        }
        return convertView;
    }



    private void setMoreClickListener(final String url, final String name, TextView tvMore,final int pos) {
        tvMore.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBean eventBean = new EventBean();
                eventBean.setTitle(name);
                eventBean.setPosition(pos);
                UmengEventUtil.addRightTopBtnEvent(context,eventBean,sexType,pageType);
                goToNovelMoreActivity(context,url, name, sexType);
            }
        });

    }

    private void setListener(final ViewHolder viewHolder, final DFHomeNovelBeans tempHomeBean, final int pos) {

        viewHolder.rela1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                EventBean eventBean = new EventBean();
                eventBean.setTitle(tempHomeBean.getTitle());
                eventBean.setPosition(pos);
                UmengEventUtil.addContentEvent(context,eventBean,sexType,pageType);
                goToNovelDesActivity(context,String.valueOf(tempHomeBean.getId()),
                        tempHomeBean.getObject_type(), tempHomeBean.getTitle(), sexType,cardTitle);
            }
        });

        viewHolder.tv_tag11.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goToTagActivity(context,viewHolder.tv_tag11.getText().toString(),sexType);
            }
        });
        viewHolder.tv_tag12.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                goToTagActivity(context,viewHolder.tv_tag12.getText().toString(),sexType);
            }
        });
    }

    public static void goToTagActivity(Context context,String tagName,String sexType) {
        setType(sexType);
        TagsUtil.openWeexTagActivity(context,tagName,Constant.OBJECT_TYPE_NOVEL,sexType);
    }



    public static void goToNovelMoreActivity(Context context,String url, String name,String type) {
        setType(type);
        Intent intent = new Intent();
        intent.putExtra(Constant.URL, url);
        intent.putExtra("IS_FROMHOME", true);
        intent.putExtra(Constant.TITLE, name);
        new StartActivityUtils(context, intent).toNovelMoreActivity();
    }

    public static void goToNovelMoreWeexActivity(Context context, String url,String type) {
        setType(type);
        Intent intent = new Intent();
        intent.putExtra(Constant.URL, url);
        new StartActivityUtils(context,intent).toNovelMoreWeexActivity();
    }

    public static void setType(String type) {
        if (type != null) {
            ((WeMediaApplication) (WeMediaApplication.applicationContext)).sexType = type;
        }
    }

    public static void goToNovelDesActivity(Context context,String novelId, String novelType, String fromTitleName,String type,String cardTitle) {
        setType(type);
        NovelDetailsActivity.Companion.startActivity(context,novelId,Intent.FLAG_ACTIVITY_NEW_TASK);

        String prePageName;
        if ("-1".equals(type)) {
            prePageName = "newVip";
        }else if ("1".equals(type)) {//彩虹
            prePageName = "rainbow";
        } else if ("3".equals(type)) {
            prePageName = "romance";
        }else {
            prePageName = "samePerson";
        }
        UserLogManager.addLog(UserLogManager.LOG_EVENT_NAME_NOVEL_DETAIL,novelId,cardTitle, prePageName,"TFNovelDetail.js");

        // 统计事件
        Map<String, String> analysisMap = new HashMap<String, String>();
        analysisMap.put("mpositon", "0");
        analysisMap.put("mid", novelId);
        analysisMap.put("mtype", novelType);
        TMAnalysis.event(context, fromTitleName, analysisMap);
    }

    private void setData(ViewHolder viewHolder, DFHomeNovelBeans tempHomeBean,int pos) {
        setTagVisibnle(tempHomeBean.isShowTag, viewHolder);
        if (tempHomeBean != null) {
            if ("1".equals(tempHomeBean.getIs_vip())) {
                viewHolder.imgVip.setVisibility(View.VISIBLE);
            } else {
                viewHolder.imgVip.setVisibility(View.GONE);
            }
            if (tempHomeBean.hasTitleA) {//需要显示前面标题
                viewHolder.linearLayout0.setVisibility(View.VISIBLE);
                viewHolder.tv_bigtitle.setText(tempHomeBean.upTitleNameA);
                if (!TextUtils.isEmpty(tempHomeBean.upTitleNameA)){
                    cardTitle = tempHomeBean.upTitleNameA;
                }
                if (tempHomeBean.isMoreUrlA) {
                    viewHolder.tv_more.setVisibility(View.VISIBLE);
                    setMoreClickListener(tempHomeBean.moreUrlAddress, tempHomeBean.upTitleNameA, viewHolder.tv_more,pos);
                } else {
                    viewHolder.tv_more.setVisibility(View.INVISIBLE);
                }
            } else {
                viewHolder.linearLayout0.setVisibility(View.GONE);
            }
            viewHolder.tv_title1.setText(tempHomeBean.getTitle());
            if ((tempHomeBean.getDescription2() != null) && (tempHomeBean.getDescription2().length() > 0)) {
                viewHolder.tv_des1.setText(StringUtil.filterLineFeed(tempHomeBean.getDescription2()));
            } else {
                viewHolder.tv_des1.setText(StringUtil.filterLineFeed(tempHomeBean.getDes()));
            }
            viewHolder.tv_author1.setText(tempHomeBean.getAuthor());
            if ((tempHomeBean.getTags() != null) && (tempHomeBean.getTags().length > 0)) {
                if (tempHomeBean.getTags()[0] != null) {
                    viewHolder.tv_tag11.setText((tempHomeBean.getTags()[0]).getName());
                    viewHolder.tv_tag11.setVisibility(View.VISIBLE);
                }else{
                    viewHolder.tv_tag11.setVisibility(View.GONE);
                }
                if ((tempHomeBean.getTags().length > 1) && (tempHomeBean.getTags()[1] != null)) {
                    viewHolder.tv_tag12.setText((tempHomeBean.getTags()[1]).getName());
                    viewHolder.tv_tag12.setVisibility(View.VISIBLE);
                }else{
                    viewHolder.tv_tag12.setVisibility(View.GONE);

                }
            }else{
                viewHolder.tv_tag11.setVisibility(View.GONE);
                viewHolder.tv_tag12.setVisibility(View.GONE);
            }
            if (tempHomeBean.getImages() != null && tempHomeBean.getImages().length > 0) {
                if ((tempHomeBean.getImages()[0].getImgUrl() != null) && (tempHomeBean.getImages()[0].getImgUrl().length() > 0)) {
                    GlideUtil.displayRoundImage(context,viewHolder.novelIcon1, tempHomeBean.getImages()[0].getImgUrl(),3,R.drawable.img_default_loading_l);
                }
            }

        }
    }

    private void setTagVisibnle(boolean isShow, ViewHolder viewHolder) {
        if (isShow) {
            viewHolder.tv_tag11.setVisibility(View.VISIBLE);
            viewHolder.tv_tag12.setVisibility(View.VISIBLE);
        } else {
            viewHolder.tv_tag11.setVisibility(View.VISIBLE);
            viewHolder.tv_tag12.setVisibility(View.VISIBLE);
        }
    }

    class ViewHolder {
        private TextView tv_bigtitle;//编辑推荐等大标题
        private ImageView novelIcon1;//小说左边图片
        private TextView tv_title1;//小说标题
        private TextView tv_des1;//小说描述
        private TextView tv_author1;//小说作者名字
        private TextView tv_tag11, tv_tag12, tv_more;
        private ImageView imgVip;
        private RelativeLayout rela1;
        private LinearLayout linearLayout0;
        private LinearLayout rootLayout;
    }


    private void changeDayModelBg(ViewHolder viewHolder){
        if(WeMediaApplication.getInstance().isDayNightMode_Night){
            darkBg(viewHolder);
        }else {
            dayBg(viewHolder);
        }
    }
    private void dayBg(ViewHolder viewHolder){
        viewHolder.rootLayout.setBackgroundColor(context.getResources().getColor(R.color.home_list_item_color));
        viewHolder.linearLayout0.setBackgroundColor(context.getResources().getColor(R.color.white));
        viewHolder.tv_bigtitle.setTextColor(context.getResources().getColor(R.color.text_color_1));
        viewHolder.tv_more.setTextColor(context.getResources().getColor(R.color.text_color_6C788A));
        viewHolder.rela1.setBackgroundColor(context.getResources().getColor(R.color.white));
        viewHolder.tv_title1.setTextColor(context.getResources().getColor(R.color.text_color_1));
        viewHolder.tv_des1.setTextColor(context.getResources().getColor(R.color.text_color_727885));
        viewHolder.tv_author1.setTextColor(context.getResources().getColor(R.color.text_color_8993A3));
        viewHolder.tv_tag11.setTextColor(context.getResources().getColor(R.color.text_color_8993A3));
        viewHolder.tv_tag11.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.bg_tag_gray));
        viewHolder.tv_tag12.setTextColor(context.getResources().getColor(R.color.text_color_8993A3));
        viewHolder.tv_tag12.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.bg_tag_gray));
        viewHolder.novelIcon1.setAlpha(1.0f);
        viewHolder.imgVip.setAlpha(1.0f);
    }
    private void darkBg(ViewHolder viewHolder){
        viewHolder.rootLayout.setBackgroundColor(context.getResources().getColor(R.color.bg_dark));
        viewHolder.linearLayout0.setBackgroundColor(context.getResources().getColor(R.color.fg_dark));
        viewHolder.tv_bigtitle.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.tv_more.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.rela1.setBackgroundColor(context.getResources().getColor(R.color.fg_dark));
        viewHolder.tv_title1.setTextColor(context.getResources().getColor(R.color.title_text_dark));
        viewHolder.tv_des1.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.tv_author1.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.tv_tag11.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.tv_tag11.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.bg_tag_gray_dark));
        viewHolder.tv_tag12.setTextColor(context.getResources().getColor(R.color.text_dark));
        viewHolder.tv_tag12.setBackgroundDrawable(context.getResources().getDrawable(R.drawable.bg_tag_gray_dark));
        viewHolder.novelIcon1.setAlpha(Constant.imagViewAlpha);
        viewHolder.imgVip.setAlpha(Constant.imagViewAlpha);
    }
}
